import requests

word = input("请输入您要爬取的xx吧的页面数据代码：")
url1 = f'https://tieba.baidu.com/f'


kv = {
    'ie':'utf-8',
    'kw':word,
    'fr':'search'
}

headers = {
    'cookie':'BIDUPSID=AA838A76083CEB6F9392D611EC91A94B; PSTM=1732958112; BAIDUID=AA838A76083CEB6F03E13A2CEB23C2F8:FG=1; H_WISE_SIDS=60273_61027_61097_61207_61212_61209_61215_61243_61278; H_WISE_SIDS_BFESS=60273_61027_61097_61207_61212_61209_61215_61243_61278; BDORZ=B490B5EBF6F3CD402E515D22BCDA1598; BA_HECTOR=2184208hah840k2ha08120251fu2tg1jktefo1u; BAIDUID_BFESS=AA838A76083CEB6F03E13A2CEB23C2F8:FG=1; ZFY=1y833Q31xb06AZBMluLdH4RtEfD0ck53fPw7oaeljvY:C; PSINO=7; delPer=0; H_PS_PSSID=60273_61027_61097_61207_61212_61209_61215_61243_61278_60853; BAIDU_WISE_UID=wapp_1733213858519_800; USER_JUMP=-1; Hm_lvt_292b2e1608b0823c1cb6beef7243ef34=1733213859; HMACCOUNT=51CFE8B0D92C936E; st_key_id=17; arialoadData=false; ppfuid=FOCoIC3q5fKa8fgJnwzbE67EJ49BGJeplOzf+4l4EOvDuu2RXBRv6R3A1AZMa49I27C0gDDLrJyxcIIeAeEhD8JYsoLTpBiaCXhLqvzbzmvy3SeAW17tKgNq/Xx+RgOdb8TWCFe62MVrDTY6lMf2GrfqL8c87KLF2qFER3obJGlcv8RcA1xQKfriWJVc7a+LGEimjy3MrXEpSuItnI4KD4+dC4ek0uz7F7aOJq5Ak4V1C/dueIWI9VnKcSngfasYt3fZmLc3qhbM5H8c0GsBTRJsVwXkGdF24AsEQ3K5XBbh9EHAWDOg2T1ejpq0s2eFy9ar/j566XqWDobGoNNfmfpaEhZpob9le2b5QIEdiQcF+6iOKqU/r67N8lf+wxW6FCMUN0p4SXVVUMsKNJv2T2Q0Rs14gDuqHJ3rxHJuOGO4LkPV+7TROLMG0V6r0A++zkWOdjFiy1eD/0R8H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q1NDBhOWI1ZjZiMzAzODk1Y2VkN2UzMGQzMA==; st_data=6a5e48e708ad9be89d962356b621d0234cd194a58f43b63ac8bb2a0dcaa9104706db6052e8dd53e7b2521420079c64002c16b662958c80e9153ad7deb6a9e70e09f490664562ba23e0c02a373ebf4302157db91909a4b3e55b33c56e24b6abc56e2625664f3b28172f1cbc5924cc0f0e4cba1abdd3c049ad8bc240326745e3c4b945abe7c1d08c1983c50b143cbd652d; st_sign=169d3a4f; XFCS=EF9F9CE69552E325176C92173F8C4B60148F2DB7710D62DDBE68A17EDB5BAD81; XFT=JnEo5NUzXKIrmoJDrIevTIyvdqRivSflntiJXoFmdDo=; RT="z=1&dm=baidu.com&si=60d76279-34d6-492b-8f71-11f24dac0722&ss=m486s0vx&sl=2&tt=5jy&bcn=https%3A%2F%2Ffclog.baidu.com%2Flog%2Fweirwood%3Ftype%3Dperf&ld=qm8&ul=vui"',
    'host':'tieba.baidu.com',
    'referer':'https://www.baidu.com/link?url=rGvHahutzKzGqLQiNPa4pGjb7TSHyo9DKQc9ojiM35D8N2fi_SqwupQmv1KpTSIm&wd=&eqid=d47e93290043aa3900000006674ebe9b',
    'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36'
}

r1 = requests.get(url1, headers=headers, params=kv)
# 默认响应的结果文本编码是ISO-8859-1
r1.encoding = 'UTF-8'  # content-type:text/html; charset=utf-8
# r1.encoding = r1.apparent_encoding # 自动根据页面文本进行解析



print(r1.text) # 返回一个字符串格式的数据
# print(r1.content) # 返回一个字节格式数据